//GENERAL_OPTIONS
//GENERAL HELPERS

(function (that) {

	if(!that){
		throw "Global object missing, bitchesss";
	}

	var that = that; //local Link to Global-Object or throw Exception

	var options = {
		dummy_ident: "canv",
		canvas_list: {},
		canvas_numeric: [],
		z_current: 500,
		z_step: 250
	};

	var set_dummy = function(){

		options.dummy = options.dummy || document.getElementById(options.dummy_ident);

		return options.dummy;
	}

	that.push_canvas = function(canvas, name ){
		if(!name){return};

		options.canvas_numeric.push(name);
		options.canvas_list[name] = canvas;
	};

	that.create_canvas = function(name, no_dom){
		if(!name){return};
		var new_canvas = document.createElement('canvas');

		if(!no_dom){
			var z_index = options.z_current
			, dummy = options.dummy || set_dummy();
			options.z_current += options.z_step;

			new_canvas.style.zIndex = z_index;
			dummy.appendChild(new_canvas);
		}

		that.push_canvas(new_canvas, name);

		return new_canvas;

	}

	that.get_canvas = function(name_or_num){
		return isNaN(name_or_num) ? canvas_list[name_or_num] : canvas_list[canvas_numeric[name_or_num]];
	}


})(sauberfant);
